<?php use_javascripts_for_form($form) ?>
<div id="form">
    <a href="<?php echo url_for('sales/indexPnp') ?>" class="bt_back"><img src="<?php echo image_path('Buttons/bt_arrow_back.png') ?>" onmouseover="this.src='<?php echo image_path('Buttons/bt_arrow_back_hov.png') ?>'" onmouseout="this.src='<?php echo image_path('Buttons/bt_arrow_back.png') ?>'"></a>
    
    <form action="<?php echo url_for('sales/'.($form->getObject()->isNew() ? 'createPart' : 'updatePart').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
        <?php if (!$form->getObject()->isNew()): ?>
            <input type="hidden" name="sf_method" value="put" />
        <?php endif; ?>
        <fieldset>
            <legend class="bold">General information</legend>
            <p style="color:red;">* required to be filled in</p>
            <table>
                <tr>
                    <td class="left_title">Material No.: *</td>
                    <td class="left_input"><?php echo $form['part_number']->render() ?></td>
                    <td class="left_error"><?php echo $form['part_number']->renderError() ?></td>
                    <td class="right_title">Unit:</td>
                    <td class="right_input"><?php echo $form['unit']->render() ?></td>
                    <td class="right_error"><?php echo $form['unit']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title">Name: *</td>
                    <td class="left_input"><?php echo $form['name']->render() ?></td>
                    <td class="left_error"><?php echo $form['name']->renderError() ?></td>
                    <td class="middle_title">Type:</td>
                    <td class="middle_input"><?php echo $form['type']->render() ?></td>
                    <td class="middle_error"><?php echo $form['type']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title">Selling price (excl. VAT):</td>
                    <td class="left_input"><?php echo $form['price']->render() ?></td>
                    <td class="left_error"><?php echo $form['price']->renderError() ?></td>
                    <td class="right_title">VAT Selling Price(in %):</td>
                    <td class="right_input"><?php echo $form['VAT']->render() ?></td>
                    <td class="right_error"><?php echo $form['VAT']->renderError() ?></td>
                </tr>
            </table>
            <table>
                <tr><td>Description:</td></tr>
                <tr>
                    <td><?php echo $form['description']->render() ?></td>
                </tr>
            </table>
        </fieldset>
        <fieldset>
            <legend class="bold">Stock information</legend>
            <table>
                <tr>
                    <td class="left_title">Min Stock: *</td>
                    <td class="left_input"><?php echo $form['min_stock']->render() ?></td>
                    <td class="left_error"><?php echo $form['min_stock']->renderError() ?></td>
                </tr>
                <tr>
                    <td class="left_title">Location:</td>
                    <td class="left_input"><?php echo $form['location']->render() ?></td>
                    <td class="left_error"><?php echo $form['location']->renderError() ?></td>
                    <?php if($sf_user->isSuperAdmin()) { ?>
                        <td class="right_title">Stock: *</td>
                        <td class="right_input"><?php echo $form['stock']->render() ?></td>
                        <td class="right_error"><?php echo $form['stock']->renderError() ?></td>
                    <?php } ?>
            </table>                
        </fieldset>
        <?php if($form->getObject()->isNew()) { $form->setDefaultValues(); } ?>
        <input type="submit" value="" class="ok"/>
       <!---  <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'sales/deletePart?id=' . $form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
        <?php endif; ?> --->
        <div class="hidden_csrf"><?php echo $form['_csrf_token']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['reserved']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['in_production']->renderRow(); ?></div>
        <div class="hidden_csrf"><?php echo $form['ordered']->renderRow(); ?></div>
        <?php if(!$sf_user->isSuperAdmin()) { ?>
                <div class="hidden_csrf"><?php echo $form['stock']->renderRow(); ?></div>
        <?php } ?>
    </form>
</div>
